/************************************************************************************************
 * Copyright (c) 2015. Lorem ipsum dolor sit amet, consectetur adipiscing elit.                 *
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.  *
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.                             *
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.                                                 *
 ************************************************************************************************/

package me.send.common.captcha;

import com.octo.captcha.service.image.DefaultManageableImageCaptchaService;

/**
 * @author MaxMin.
 */

public class ManageableImageCaptchaService extends DefaultManageableImageCaptchaService {

    public ManageableImageCaptchaService(
            com.octo.captcha.service.captchastore.CaptchaStore captchaStore,
            com.octo.captcha.engine.CaptchaEngine captchaEngine,
            int minGuarantedStorageDelayInSeconds,
            int maxCaptchaStoreSize,
            int captchaStoreLoadBeforeGarbageCollection) {
        super(captchaStore, captchaEngine, minGuarantedStorageDelayInSeconds,
                maxCaptchaStoreSize, captchaStoreLoadBeforeGarbageCollection);
    }

    public boolean hasCapcha(String id, String userCaptchaResponse) {
        if (store.getCaptcha(id)!=null){
            return store.getCaptcha(id).validateResponse(userCaptchaResponse);
        }
        return false;
    }
}
